function isIntersect(rect1, rect2) {
  if (!rect1 || !rect2) {
    return false;
  }

  const { x: x1, y: y1, width: width1, height: height1 } = rect1;
  const { x: x2, y: y2, width: width2, height: height2 } = rect2;

  if (width1 <= 0 || height1 <= 0 || width2 <= 0 || height2 <= 0) {
    return false;
  }

  const x = Math.max(x1, x2);
  const y = Math.max(y1, y2);
  const right = Math.min(x1 + width1, x2 + width2);
  const bottom = Math.min(y1 + height1, y2 + height2);

  return right > x && bottom > y;
}
